package com.yidu.BusinessParament.controller;


import com.yidu.BusinessParament.entity.ExchangeRate;
import com.yidu.BusinessParament.service.ExchangeRateService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


import java.util.Map;

/**
 * @author 苏彬
 * @date 2022/12/9 13:44
 **/
@RestController
public class ExchangeRateController {
    @Autowired
    private ExchangeRateService rateService;

    /**
     * 分页+模糊查
     *
     * @param page             当前页
     * @param row              每行显示数
     * @param exchangeRateName 交易所
     * @param exchangeType     交易品种类型
     * @return Map layui需要的map
     */
    @RequestMapping("/selectExchangeRate")
    public Map selectExchangeRate(int page, int row, @RequestParam(defaultValue = "-1") int exchangeRateName, @RequestParam(defaultValue = "-1") int exchangeType) {
        return rateService.selectExchangeRateLimit(page, row, exchangeRateName, exchangeType);
    }

    /**
     * 删除+批量删
     *
     * @param myArr 要删除的id
     */
    @RequestMapping("/deleteExchangeRate")
    public void deleteExchangeRate(String myArr) {
        rateService.deleteExchangeRate(myArr);
    }

    /**
     * 增加
     *
     * @param rate 要增加的对象
     */
    @RequestMapping("/addExchangeRate")
    public int addExchangeRate(ExchangeRate rate) {
        return rateService.addExchangeRate(rate);
    }


    /**
     * 修改
     *
     * @param rate 要修改的对象
     * @return msg
     */
    @RequestMapping("/updateExchangeRate")
    public String updateExchangeRate(ExchangeRate rate) {
        return rateService.updateExchangeRate(rate);
    }
}
